// Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: DServer support simple entity
// feature: discovery support client and server
// feature: add exception code
// feature: Dynamic types support mutable and id
// ------------------------------------------------------------------

#ifndef INCLUDE_ERTPS_TYPES_TYPESBASE_H_
#define INCLUDE_ERTPS_TYPES_TYPESBASE_H_

#include <deps/type/TypesBase.h>

namespace evbs {
namespace edds {
namespace dds {
using DomainId_t = vbs::common::types::DomainId_t;
const DomainId_t DOMAIN_ID_UNKNOWN = vbs::common::types::DOMAIN_ID_UNKNOWN;
const DomainId_t DOMAIN_ID_MAX = vbs::common::types::DOMAIN_ID_MAX;
}  // namespace dds
}  // namespace edds
using vbsutil::elog::ReturnCode_t;

namespace ertps {
namespace types {

//! A special value indicating an unlimited quantity
using vbs::common::types::BOUND_UNLIMITED;

using vbs::common::types::OctetSeq;

using vbs::common::types::CONST_FALSE;
using vbs::common::types::CONST_TRUE;

using vbs::common::types::ANNOTATION_APPENDABLE_ID;
using vbs::common::types::ANNOTATION_BIT_BOUND_ID;
using vbs::common::types::ANNOTATION_COMPATIBLE;
using vbs::common::types::ANNOTATION_DEFAULT_ID;
using vbs::common::types::ANNOTATION_DEFAULT_LITERAL_ID;
using vbs::common::types::ANNOTATION_EPKEY_ID;
using vbs::common::types::ANNOTATION_EXTENSIBILITY_ID;
using vbs::common::types::ANNOTATION_FINAL_ID;
using vbs::common::types::ANNOTATION_ID;
using vbs::common::types::ANNOTATION_KEY_ID;
using vbs::common::types::ANNOTATION_MUST_UNDERSTAND_ID;
using vbs::common::types::ANNOTATION_MUTABLE_ID;
using vbs::common::types::ANNOTATION_NESTED_ID;
using vbs::common::types::ANNOTATION_NON_SERIALIZED_ID;
using vbs::common::types::ANNOTATION_OPTIONAL_ID;
using vbs::common::types::ANNOTATION_POSITION_ID;
using vbs::common::types::ANNOTATION_TOPIC_ID;
using vbs::common::types::ANNOTATION_VALUE_ID;

using vbs::common::types::EXTENSIBILITY_APPENDABLE;
using vbs::common::types::EXTENSIBILITY_FINAL;
using vbs::common::types::EXTENSIBILITY_MUTABLE;

using vbs::common::types::TKNAME_BOOLEAN;
using vbs::common::types::TKNAME_BYTE;
using vbs::common::types::TKNAME_CHAR16;
using vbs::common::types::TKNAME_CHAR16T;
using vbs::common::types::TKNAME_CHAR8;
using vbs::common::types::TKNAME_FLOAT128;
using vbs::common::types::TKNAME_FLOAT32;
using vbs::common::types::TKNAME_FLOAT64;
using vbs::common::types::TKNAME_INT16;
using vbs::common::types::TKNAME_INT32;
using vbs::common::types::TKNAME_INT64;
using vbs::common::types::TKNAME_INT8;
using vbs::common::types::TKNAME_UINT16;
using vbs::common::types::TKNAME_UINT32;
using vbs::common::types::TKNAME_UINT64;
using vbs::common::types::TKNAME_UINT8;
using vbs::common::types::TKNAME_ULL;

using vbs::common::types::TKNAME_ALIAS;
using vbs::common::types::TKNAME_ANNOTATION;
using vbs::common::types::TKNAME_ARRAY;
using vbs::common::types::TKNAME_BITMASK;
using vbs::common::types::TKNAME_BITSET;
using vbs::common::types::TKNAME_ENUM;
using vbs::common::types::TKNAME_MAP;
using vbs::common::types::TKNAME_SEQUENCE;
using vbs::common::types::TKNAME_STRING16;
using vbs::common::types::TKNAME_STRING8;
using vbs::common::types::TKNAME_STRUCTURE;
using vbs::common::types::TKNAME_UNION;

// ---------- Equivalence Kinds ------------------
using vbs::common::types::EK_COMPLETE;  // 0x1111 0001
using vbs::common::types::EquivalenceKind;

// ---------- TypeKinds (begin) ------------------
using vbs::common::types::TypeKind;  // Primitive TKs

using vbs::common::types::TK_BOOLEAN;
using vbs::common::types::TK_BYTE;
using vbs::common::types::TK_CHAR16;
using vbs::common::types::TK_CHAR8;
using vbs::common::types::TK_FLOAT128;
using vbs::common::types::TK_FLOAT32;
using vbs::common::types::TK_FLOAT64;
using vbs::common::types::TK_INT16;
using vbs::common::types::TK_INT32;
using vbs::common::types::TK_INT64;
using vbs::common::types::TK_INT8;
using vbs::common::types::TK_NONE;
using vbs::common::types::TK_UINT16;
using vbs::common::types::TK_UINT32;
using vbs::common::types::TK_UINT64;

// String TKs
using vbs::common::types::TK_STRING16;
using vbs::common::types::TK_STRING8;

// Constructed/Named types
using vbs::common::types::TK_ALIAS;

// Enumerated TKs
using vbs::common::types::TK_BITMASK;
using vbs::common::types::TK_ENUM;

// Structured TKs
using vbs::common::types::TK_ANNOTATION;
using vbs::common::types::TK_BITSET;
using vbs::common::types::TK_STRUCTURE;
using vbs::common::types::TK_UNION;

// Collection TKs
using vbs::common::types::TK_ARRAY;
using vbs::common::types::TK_MAP;
using vbs::common::types::TK_SEQUENCE;

// ---------- TypeKinds (end) ------------------

// The name of some element (e.g. type, type member, module)
// Valid characters are alphanumeric plus the "_" cannot start with digit
using vbs::common::types::MEMBER_NAME_MAX_LENGTH;
using vbs::common::types::MemberName;

// Qualified type name includes the name of containing modules
// using "::" as separator. No leading "::". E.g. "MyModule::MyType"
using vbs::common::types::QualifiedTypeName;
using vbs::common::types::TYPE_NAME_MAX_LENGTH;

// Every type has an ID. Those of the primitive types are pre-defined.
using vbs::common::types::PrimitiveTypeId;

// First 4 bytes of MD5 of of a member name converted to bytes
// using UTF-8 encoding and without a 'nul' terminator.
// Example: the member name "color" has NameHash {0x70, 0xDD, 0xA5, 0xDF}
using vbs::common::types::NameHash;

// Mask used to remove the flags that do no affect assignability
// Selects  T1, T2, O, M, K, D
using vbs::common::types::MemberFlagMinimalMask;

using vbs::common::types::MEMBER_ID_INVALID;
using vbs::common::types::MemberId;
// #define MEMBER_ID_INVALID 0X0FFFFFFFU
#define INDEX_INVALID UINT32_MAX
#define CDR_ID_INVALID UINT16_MAX

using vbs::common::types::MAX_BITMASK_LENGTH;
using vbs::common::types::MAX_ELEMENTS_COUNT;
using vbs::common::types::MAX_STRING_LENGTH;

// Long Bound of a collection type
using vbs::common::types::INVALID_LBOUND;
using vbs::common::types::LBound;
using vbs::common::types::LBoundSeq;

// Short Bound of a collection type
using vbs::common::types::INVALID_SBOUND;
using vbs::common::types::SBound;
using vbs::common::types::SBoundSeq;
using MemberFlag = vbs::common::types::MemberFlag;

using vbs::common::types::AliasMemberFlag;          // Unused. No flags apply
using vbs::common::types::AnnotationParameterFlag;  // Unused. No flags apply
using vbs::common::types::BitflagFlag;              // Unused. No flags apply
using vbs::common::types::BitsetMemberFlag;         // Unused. No flags apply
using vbs::common::types::CollectionElementFlag;    // T1, T2, X
using vbs::common::types::EnumeratedLiteralFlag;    // D
using vbs::common::types::StructMemberFlag;         // T1, T2, O, M, K, X
using vbs::common::types::UnionDiscriminatorFlag;   // T1, T2, K
using vbs::common::types::UnionMemberFlag;          // T1, T2, D, X

using TypeFlag = vbs::common::types::TypeFlag;

using vbs::common::types::AliasTypeFlag;       // Unused. No flags apply
using vbs::common::types::AnnotationTypeFlag;  // Unused. No flags apply
using vbs::common::types::BitmaskTypeFlag;     // Unused. No flags apply
using vbs::common::types::BitsetTypeFlag;      // Unused. No flags apply
using vbs::common::types::CollectionTypeFlag;  // Unused. No flags apply
using vbs::common::types::EnumTypeFlag;        // Unused. No flags apply
using vbs::common::types::StructTypeFlag;      // All flags apply
using vbs::common::types::UnionTypeFlag;       // All flags apply

// Mask used to remove the flags that do no affect assignability
using vbs::common::types::TypeFlagMinimalMask;  // Selects  M, A, F

// --- Annotation usage: ----------------------------------------------

// ID of a type member
using vbs::common::types::ANNOTATION_OCTETSEC_VALUE_MAX_LEN;
using vbs::common::types::ANNOTATION_STR_VALUE_MAX_LEN;

}  // namespace types
}  // namespace ertps
}  // namespace evbs

#define VBS_TOOL_WAIT_TIMEOUT 1000

#endif  // INCLUDE_COMMON_TYPES_TYPESBASE_H_
